import { domainService } from '~/config/server';
import { NetService } from '~/utils/net.service';
import { Inject, Debounce } from "~/core/decorator";
import { Service } from '~/core/service';
import { FilterService } from '~/utils/filter.service';

export class CaseVerifyService extends Service {

  @Inject(NetService)
  private netService: NetService

  /**
   * 查询待核销案信息
   * @param 查询条件
   * @page 页码信息
   */
  public getAllVerifyInfos(data, page) {
    return this.netService.send({
      server: domainService.caseVerifyController.getAllVerifyInfos,
      data:{...data, ...{
        overdueAmountMax: data.overdueAmount.max,
        overdueAmountMin: data.overdueAmount.min,
        overdueDaysMax: data.overdueDays.max,
        overdueDaysMin: data.overdueDays.min,
        // area: data.area[data.area.length - 1]
        provinceId: data.area[0],
        cityId: data.area[1],
        countyId: data.area[2],
      }},
      page
    })
  }
  /**
   * 核销案件
   * @param data 
   */
  public verifiedCaseInfo(data){    
    return this.netService.send({
      server: domainService.caseVerifyController.verifiedCaseInfo,
      data
    })
  }

  /**
   * 附件上传
   * @param data 
   */
  public uploadCaseVerifyFile(data) {
    return this.netService.send({
      server: domainService.caseVerifyController.uploadCaseVerifyFile,
      data
    })
  }

  /**
   * 附件上传
   * @param data 
   */
  public exportVerifyInfos(data) {
    return this.netService.send({
      server: domainService.caseVerifyController.exportVerifyInfos,
      data:{...data, ...{
        overdueAmountMax: data.overdueAmount.max,
        overdueAmountMin: data.overdueAmount.min,
        overdueDaysMax: data.overdueDays.max,
        overdueDaysMin: data.overdueDays.min,
        followInTimeMin: FilterService.dateRanageFormat(data.followInTime).start,
        followInTimeMax: FilterService.dateRanageFormat(data.followInTime).end,
        provinceId: data.area[0],
        cityId: data.area[1],
        countyId: data.area[2],
      }}
    })
  }
  /**
   * 查询坏账案件
   * @param data 
   */
  public getVerifyInfosByNumber(data,page) {
    return this.netService.send({
      server: domainService.caseVerifyController.getVerifyInfosByNumber,
      data:{
        verifyBatchNumber:data
      },
      page
    })
  }
  /**
   * 查询核销案信息
   * @param 查询条件
   * @page 页码信息
   */
  public getVerifyInfoResult(data,page) {
    return this.netService.send({
      server: domainService.caseVerifyController.getVerifyInfoResult,
      data:{...data, ...{
        overdueAmountMax: data.overdueAmount.max,
        overdueAmountMin: data.overdueAmount.min,
        overdueDaysMax: data.overdueDays.max,
        overdueDaysMin: data.overdueDays.min,
        // area: data.area[data.area.length - 1]
        followInTimeMin: FilterService.dateRanageFormat(data.followInTime).start,
        followInTimeMax: FilterService.dateRanageFormat(data.followInTime).end,
        provinceId: data.area[0],
        cityId: data.area[1],
        countyId: data.area[2],
      }},
      page
    })
  }
  /**
   * 导出待核销案件
   * @param data 
   */
  public exportWaitVerifyInfos(data) {
    return this.netService.send({
      server: domainService.caseVerifyController.exportWaitVerifyInfos,
      data:{...data, ...{
        overdueAmountMax: data.overdueAmount.max,
        overdueAmountMin: data.overdueAmount.min,
        overdueDaysMax: data.overdueDays.max,
        overdueDaysMin: data.overdueDays.min,
        // area: data.area[data.area.length - 1]
        provinceId: data.area[0],
        cityId: data.area[1],
        countyId: data.area[2],
      }},
    })
  }

  /**
   * 获取需要确认的待核销案件信息
   * @param data 
   */
  public getWaitVerifyConfirmInfos(data,page) {
    return this.netService.send({
      server: domainService.caseVerifyController.getWaitVerifyConfirmInfos,
      data:{
        caseNumber: data.caseNumber,
        personalName: data.personalName,
        personalNo: data.personalNo,
        verifyBatchNumber: data.verifyBatchNumber,
        caseIds: data.caseIds,
      },
      page
    })
  }

}

